﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;


namespace IHISCETeim.Web.MachineSys.UserModel
{
    public partial class UFXCompletingCheckList : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.查看, Permission.修改, Permission.新增, Permission.删除 };
            }
        }
        protected override string DWZRef
        {
            get
            {
                return "UFXCompletingCheckList";
            }
        }
        #region 属性 (查询条件)

        protected override string orderField
        {
            get
            {
                return string.IsNullOrEmpty(base.orderField) ? "SerialNumber" : base.orderField;
            }
        }
        protected override string orderDirection
        {
            get
            {
                return string.IsNullOrEmpty(base.orderDirection) ? "Asc" : base.orderDirection;
            }
        }

        protected string CommonFiled
        {
            get
            {
                return GetRequestValue<string>("CommonFiled", "");

            }
        }
        protected string CommonValue
        {
            get
            {
                return GetRequestValue<string>("CommonValue", "");

            }
        }
        protected string DownlineDateFrom
        {
            get
            {
                return GetRequestValue<string>("DownlineDateFrom", "");

            }
        }
        protected string DownlineDateTo
        {
            get
            {
                return GetRequestValue<string>("DownlineDateTo", "");

            }
        }

        protected string GetViewUrl(object tempMachineType,object SerialNumber,int type)
        {
            string MachineType = tempMachineType.ToString().ToLower();
            string strUrl = "UserModel/{0}.aspx?Id={1}";
            string editstrUrl = "UserModel/{0}.aspx?Id={1}";
            switch (MachineType)
            {
                case "40ns":
                    strUrl = string.Format(type == 0 ? strUrl : editstrUrl, type == 0 ? "UFXOC40NSView" : "UFXOC40NSEdit", SerialNumber);
                    break;
                case "55nsl":
                    strUrl = string.Format(type == 0 ? strUrl : editstrUrl, type == 0 ? "UFXOC55NSLView" : "UFXOC55NSLEdit", SerialNumber);
                    break;
                case "65ns":
                    strUrl = string.Format(type == 0 ? strUrl : editstrUrl, type == 0 ? "UFXOC65NSView" : "UFXOC65NSEdit", SerialNumber);
                    break;
                case "65nsl":
                    strUrl = string.Format(type == 0 ? strUrl : editstrUrl, type == 0 ? "UFXOC65NSLView" : "UFXOC65NSLEdit", SerialNumber);
                    break;
                case "80ns":
                    strUrl = string.Format(type == 0 ? strUrl : editstrUrl, type == 0 ? "UFXOC80NSView" : "UFXOC80NSEdit", SerialNumber);// string.Format(strUrl, "OC80NSView", SerialNumber);
                    break;
                case "100ns":
                    strUrl = string.Format(type == 0 ? strUrl : editstrUrl, type == 0 ? "UFXOC100NSView" : "UFXOC100NSEdit", SerialNumber);// string.Format(strUrl, "OC80NSView", SerialNumber);
                    break;
                case "100nst":
                    strUrl = string.Format(type == 0 ? strUrl : editstrUrl, type == 0 ? "UFXOC100NSTView" : "UFXOC100NSTEdit", SerialNumber);// string.Format(strUrl, "OC80NSView", SerialNumber);
                    break;
                case "68ns":
                    strUrl = string.Format(type == 0 ? strUrl : editstrUrl, type == 0 ? "UFXOC68NSView" : "UFXOC68NSEdit", SerialNumber);// string.Format(strUrl, "OC80NSView", SerialNumber);
                    break;
                case "135ns":
                    strUrl = string.Format(type == 0 ? strUrl : editstrUrl, type == 0 ? "UFXOC135NSView" : "UFXOC135NSEdit", SerialNumber);// string.Format(strUrl, "OC80NSView", SerialNumber);
                    break;
            }
            return strUrl;
        }
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            DataBind();
            this.AddLog(Permission.查看, GetSql());
        }

        protected void DataBind()
        {

            this.rpMenu.DataSource = UFXCompletingCheckController.GetPagination(GetSql(), pageNum, numPerPage, base.SQLSort, ref TotalCount);
            this.rpMenu.DataBind();
        }

        protected string GetSql()
        {
            string wheresql = QueryOperatorsEnumHelper.ConvertCommonOperator(CommonFiled, QueryOperatorsEnum.包含, CommonValue);

            string DOWNSQL = "";
            if (!string.IsNullOrEmpty(DownlineDateFrom))
            {
                DOWNSQL = QueryOperatorsEnumHelper.ConvertCommonOperator("CheckDate", QueryOperatorsEnum.范围, DownlineDateFrom + "|" + DownlineDateTo);
                if (!string.IsNullOrEmpty(wheresql))
                {
                    wheresql += " and " + DOWNSQL;
                }
                else
                {
                    wheresql = DOWNSQL;
                }
            }
            return wheresql;
        }
    }
}